/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
window.AjaxContent = {};

AjaxContent.ConnectionStaticPage = function init(action){
    $.ajax({
        url: "index.php/pages/" + action + "",            
        dataType: "JSON",
        success: function(obj){
            $('#jumbotronContent').html(obj.content);
        }});
}

AjaxContent.ConnectionNews = function init(id) {
    var type;
    $.ajax({
    url: "index.php/pages/ajax_news_page/?id=" + id + "",     
    dataType: "JSON",
    success: function(obj){
       $("#newsContainer").html(obj.content);
    }});
}

$(document).ready(function(){
    $('#menu button').click(function(e){
        if($(this).attr("id") == "news")
        {
            var link = "ajax_news_list_page/";
        }
        else
        {
            var link = "ajax_static_page?subpage=" + $(this).attr("id");
        }
        var Change = new AjaxContent.ConnectionStaticPage(link);
    })   
});


function changeNewsContent(id)
{
    $("#newsList").fadeOut(400);
    AjaxContent.ConnectionNews(id);
    setTimeout(function(){$("#newsContainer").fadeIn(500)}, 400);
}

function showNewsList()
{
    $("#newsContainer").fadeOut(400);
    setTimeout(function(){$("#newsList").fadeIn(500)}, 400);
}